import { ILoadMapTypeAll } from '@/common';
import { ManageCommonAPI } from '@/pages/type';
import { getSelectDataMapList, getTenantID } from '@/utils';
import { useEffect, useState } from 'react';
import { getStorageTreeService } from '../services';

/** 物资列表搜索 */
const getMaterialSearchList = (loadInfo: Record<string, any>): ManageCommonAPI.ISearchList => {
  /**物资类型数据字典*/
  const materialTypeMapList = getSelectDataMapList(loadInfo?.loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`], 'name', 'id', true);
  return [
    {
      name: 'assetName',
      placeholder: '资产名称',
      label: '资产名称',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'assetCode',
      placeholder: '资产编号',
      label: '资产编号',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'assetClass',
      placeholder: '资产分类',
      label: '资产分类',
      componentType: 'TreeSelect',
      dataSource: materialTypeMapList,
      allowClear: true,
      showSearch: true,
      treeNodeFilterProp: 'name',
      md: 4,
      sm: 24,
      whetherSenior: false,
      fieldNames: {
        label: 'name',
        value: 'id',
        children: 'children',
      },
    },
    {
      name: 'brandType',
      placeholder: '品牌',
      label: '品牌',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'paramsInfo',
      placeholder: '规格型号',
      label: '规格型号',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
  ];
};

export { getMaterialSearchList };

// const materialTypeMapList = loadInfo?.loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`];

/** 仓库树数据 */
// const [storageList, setStorageList] = useState<any>([]);

/** 获取仓库树回调 */
// const updataGetStorage = (res: any) => {
//   if (res && res?.msgFlag) {
//     setStorageList(res?.obj);
//   }
// };

/** 获取仓库树 */
// const { getStorageLoading, getStorageRun } = getStorageTreeService(updataGetStorage, loadInfo?.curRes);

// useEffect(() => {
//   getStorageRun();
// }, []);

// {
//   name: 'assetStoreId',
//   placeholder: '所属仓库',
//   label: '所属仓库',
//   componentType: 'TreeSelect',
//   dataSource: storageList,
//   allowClear: true,
//   md: 4,
//   sm: 36,
//   whetherSenior: false,
//   fieldNames: {
//     label: 'storeName',
//     value: 'id',
//     children: 'children',
//   },
// },
